import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { SimpleGuard } from '@delon/auth';
import { environment } from '@env/environment';
// layout
import { LayoutDefaultComponent } from '../layout/default/default.component';
import { LayoutFullScreenComponent } from '../layout/fullscreen/fullscreen.component';
import { LayoutPassportComponent } from '../layout/passport/passport.component';
// dashboard pages
import { DashboardComponent } from './dashboard/dashboard.component';
// passport pages
import { UserLoginComponent } from './passport/login/login.component';
import { UserRegisterComponent } from './passport/register/register.component';
import { UserRegisterResultComponent } from './passport/register-result/register-result.component';
// single pages
import { CallbackComponent } from './callback/callback.component';
import { UserLockComponent } from './passport/lock/lock.component';

const routes: Routes = [
  {path: '', redirectTo: 'passport/login', pathMatch: 'full'},
  {
    path: '',
    component: LayoutDefaultComponent,
    canActivate: [SimpleGuard],
    children: [
      { path: 'dashboard', component: DashboardComponent, data: { title: '仪表盘', titleI18n: 'dashboard' } },
      { path: 'exception', loadChildren: () => import('./exception/exception.module').then(m => m.ExceptionModule) },
      // 业务子模块
      { path: 'shortcut', loadChildren: () => import('./shortcut/shortcut.module').then(module => module.ShortcutModule)},
      // 系统管理
      {path: 'sys-setting', loadChildren: () => import('./sys-setting/sys-setting.module').then(m => m.SysSettingModule)},
      // 人员出入管理
      {path: 'io-records-manage', loadChildren: () => import('./io-records-manage/io-records-manage.module').then(m => m.IoRecordsManageModule)},
      // 人员管理
      {path: 'person-manage', loadChildren: () => import('./person-manage/person-manage.module').then(m => m.PersonManageModule)},
      //用户管理
      {path:'user-manage',loadChildren:() => import('./user-manage/user-manage.module').then(m => m.UserManageModule)},
      //设备管理
      {path:'device-manage',loadChildren:() => import('./device-manage/device-manage.module').then(m => m.DeviceManageModule)},
       //二维码管理
       {path:'qrcode-manage',loadChildren:() => import('./qrcode-manage/qrcode-manage.module').then(m => m.QRCodeManageModule)},
       //二维码支付管理
       {path:'qrcodepay-manage',loadChildren:()=> import('./qr-code-pay-manage/qr-code-pay-manage.module').then(m=>m.QrCodePayManageModule)},
      //预警管理
      {path:'warning-manage',loadChildren:() => import('./warning-manage/warning-manage.module').then(m => m.WarningManageModule)},
      // 关注人员管理
      {path: 'watch-person-manage', loadChildren: () => import('./watch-person-manage/watch-person-manage.module').then(m => m.WatchPersonManageModule)},
      // 房屋管理
      {path: 'house-manage', loadChildren: () => import('./house-manage/house-manage.module').then(m => m.HouseManageModule)},
      // 广告管理
      {path: 'ad-manage', loadChildren: () => import('./ad-manage/ad-manage.module').then(m => m.AdManageModule)},
      // 日志管理
      {path: 'log-manage', loadChildren: () => import('./log-manage/log-manage.module').then(m => m.LogManageModule)},
      // 一机一档
      {path: 'device', loadChildren: () => import('./device/device.module').then(m => m.DeviceModule)},
       // 支付管理
       {path: 'payment-manage', loadChildren: () => import('./payment-manage/payment-manage.module').then(m => m.PaymentManageModule)},
    ]
  },
  // 全屏布局
  {
      path: 'fullscreen',
      component: LayoutFullScreenComponent,
      data: { title: '兴天下视频门禁系统', titleI18n: '兴天下视频门禁系统' } 
  },
  // passport
  {
    path: 'passport',
    component: LayoutPassportComponent,
    children: [
      { path: 'login', component: UserLoginComponent, data: { title: '登录' } },
      { path: 'register', component: UserRegisterComponent, data: { title: '注册' } },
      { path: 'register-result', component: UserRegisterResultComponent, data: { title: '注册结果', titleI18n: 'pro-register-result' } },
      { path: 'lock', component: UserLockComponent, data: { title: '锁屏', titleI18n: 'lock' } },
    ]
  },
  // 单页不包裹Layout
  { path: 'callback/:type', component: CallbackComponent },
  { path: '**', redirectTo: 'exception/404' },
];

@NgModule({
  imports: [
    RouterModule.forRoot(
      routes, {
      useHash: environment.useHash,
      // NOTICE: If you use `reuse-tab` component and turn on keepingScroll you can set to `disabled`
      // Pls refer to https://ng-alain.com/components/reuse-tab
      scrollPositionRestoration: 'top',
    }
    )],
  exports: [RouterModule],
})
export class RouteRoutingModule { }
